Simulation algorithms for atomic DEVS

Given an atomic DEVS model, simulation algorithms are methods to generate the model's legal behaviors which are trajectories not to reach to illegal states. (see Behavior of DEVS). [Zeigler84] originally introduced the algorithms that handle time variables related to lifespan t_s \in [0,\infty] and elapsed time t_e\in [0,\infty) by introducing two other time variables, last event time, t_l\in [0,\infty), and next event time  t_n\in [0,\infty] with the following relations:

 \, t_e = t - t_l

and

\, t_s = t_n - t_l

where t\in [0,\infty) denotes the current time. And the remaining time,

\,t_r=t_s-t_e

is equivalently computed as

\, t_r = t_n - t

, apparently  t_r \in [0,\infty].

Since the behavior of a given atomic DEVS model can be defined in two different views depending on the total state and the external transition function (refer to Behavior of DEVS), the simulation algorithms are also introduced in two different views as below.

Contents

Common parts

Regardless of two different views of total states, algorithms for initialization and internal transition cases are commonly defined as below.

DEVS-simulator
  variables:
    parent // parent coordinator
    t_l     // time of last event
    t_n     // time of next event
    A=(X,Y,S,ta, \delta_{ext}, \delta_{int}, \lambda) // the associated Atomic DEVS model 
  when receive init-message(Time t)
      t_l \leftarrow t;
      t_n \leftarrow t_l %2B ta(s); 
  when receive star-message(Time t)
     if  t \ne t_n  then
        error: bad synchronization;
      y \leftarrow \lambda(s);
     send y-message(y,t) to parent;
      s \leftarrow \delta_{int}(s)
      t_l \leftarrow t;
      t_n \leftarrow t_l %2B ta(s); 

View 1: total states = states * elapsed times

As addressed in Behavior of Atomic DEVS, when DEVS receives an input event, right calling \delta_{ext}, the last event time,t_l is set by the current time,t , thus the elapsed timet_e becomes zero because t_e = t - t_l.

  when receive x-message(x \in X, Time t)
     if ( t_l \le t  and  t \le t_n ) == false then
        error: bad synchronization;
      s \leftarrow \delta_{ext}(s,t-t_l, x)
      t_l \leftarrow t;
      t_n \leftarrow t_l %2B ta(s); 

View 2: total states = states * lifespans * elapsed times

Notice that as addressed in Behavior of Atomic DEVS, depending on the value of b return by  \delta_{ext}, last event time,t_l, and next event time,t_n,consequently, elapsed time, t_e, and lifespant_n, are updated (if b=1) or preserved (if b=0).

  when receive x-message(x \in X, Time t)
     if ( t_l \le t  and  t \le t_n ) == false then
        error: bad synchronization;
      (s,b) \leftarrow \delta_{ext}(s, t-t_l, x)
     if  b = 1  then 
         t_l \leftarrow t;
         t_n \leftarrow t_l %2B ta(s); 

See also

References